//
//  UserCommentView.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/10/23.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "UserCommentView.h"

@implementation UserCommentView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        /**
         用户昵称
         */
        UILabel *nickNameLabel = [[UILabel alloc] init];
        nickNameLabel.font = MidBigFont;
        nickNameLabel.text = @"昵称";
        [self addSubview:nickNameLabel];
        self.nickNameLabel = nickNameLabel;
        
        /**
         用户头像
         */
        UIImageView *userHeadImageView = [[UIImageView alloc] init];
        userHeadImageView.backgroundColor = CSRedColor;
        userHeadImageView.contentMode = UIViewContentModeScaleAspectFill;
        userHeadImageView.layer.cornerRadius = 35;
        userHeadImageView.layer.masksToBounds = YES;
        [self addSubview:userHeadImageView];
        self.userHeadImageView = userHeadImageView;
        
        
        /**
         用户评星
         */
        CommentLineInfoView *commentLineInfoView = [[CommentLineInfoView alloc] init];
        commentLineInfoView.commentCountLabel.text = @"";
        commentLineInfoView.courseCountLabel.text = @"";
        commentLineInfoView.commentLabel.text = @"";
        [self addSubview:commentLineInfoView];
        self.commentLineInfoView = commentLineInfoView;
        
        /**
         时间Label
         */
        UILabel *timeLabel = [[UILabel alloc] init];
        timeLabel.font = MidFont;
        timeLabel.text = @"09月26日 20：53";
        timeLabel.textColor = CSColorFromRGB(0xcccccc);
        [self addSubview:timeLabel];
        self.timeLabel = timeLabel;
        
        
        /**
         地址Label
         */
        UILabel *addressLabel = [[UILabel alloc] init];
        addressLabel.font = MidFont;
        addressLabel.text = @"亦庄成县店";
        addressLabel.textColor = CSColorFromRGB(0xcccccc);
        [self addSubview:addressLabel];
        self.addressLabel = addressLabel;
        
        
        /**
         评论
         */
        UILabel *commentLabel = [[UILabel alloc] init];
        commentLabel.font = MidBigFont;
        commentLabel.numberOfLines = 0;
        commentLabel.lineBreakMode = NSLineBreakByCharWrapping;
        commentLabel.text = @"身心的双重练习，老师水平高呀！！！！";
        commentLabel.textColor = CSColorFromRGB(0x333333);
        [self addSubview:commentLabel];
        self.commentLabel = commentLabel;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    
    /**
     用户头像
     */
    [self.userHeadImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
    
        make.top.left.mas_equalTo(self).offset(10);
        
        make.width.height.mas_equalTo(70);
        
    }];
    
    /**
     用户昵称
     */
    [self.nickNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.userHeadImageView);
        
        make.left.mas_equalTo(self.userHeadImageView.mas_right).offset(10);
    }];
    
    /**
     用户评星
     */
    [self.commentLineInfoView mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.right.mas_equalTo(self).offset(-30);

        make.top.mas_equalTo(self.nickNameLabel).offset(-5);
        
        make.width.mas_equalTo(100);
    }];
    
    /**
     时间Label
     */
    [self.timeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.nickNameLabel.mas_bottom).offset(10);
        
        make.left.mas_equalTo(self.nickNameLabel);
    }];
    
    
    /**
     地址Label
     */
    [self.addressLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.timeLabel);
        
        make.left.mas_equalTo(self.timeLabel.mas_right).offset(10);
    }];
    
    
    /**
     评论
     */
    [self.commentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.timeLabel);
        
        make.top.mas_equalTo(self.timeLabel.mas_bottom).offset(20);
        
        make.bottom.right.mas_equalTo(self).offset(-10);
    }];
}

@end


/**
 详情View 地址什么的
 */
@implementation InfoView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        /**
         标题图片
         */
        UIImageView *titleImageView = [[UIImageView alloc] init];
        [self addSubview:titleImageView];
        self.titleImageView = titleImageView;
        
        /**
         标题
         */
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.text = @"标题";
        titleLabel.font = BoldMidBigFont;
        [self addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        /**
         详情
         */
        UILabel *detailLabel = [[UILabel alloc] init];
        detailLabel.font = MidFont;
        detailLabel.textColor = CSColorFromRGB(0xb3b3b3);
        [self addSubview:detailLabel];
        self.detailLabel = detailLabel;
        
        UIView *lineView= [[UIView alloc] init];
        lineView.backgroundColor = CSColorFromRGB(0xe6e6e6);
        [self addSubview:lineView];
        self.lineView = lineView;;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    /**
     标题图片
     */
    [self.titleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self).offset(25);
        
        make.left.mas_equalTo(self).offset(17);
        
        make.bottom.mas_equalTo(self).offset(-25);
    }];
    
    /**
     标题
     */
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self).offset(15);
        
        make.left.mas_equalTo(self.titleImageView.mas_right).offset(15);
    }];
    
    /**
     详情
     */
    [self.detailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.titleLabel);
        
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(5);
    }];
    
    [self.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.titleImageView);
        make.bottom.right.mas_equalTo(self);
        make.height.mas_equalTo(1);
    }];
}

@end


/**
 教练Cell
 */
@implementation ClassCoachCollectionViewCell

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        /**
         背景图片
         */
        UIImageView *imageView = [[UIImageView alloc] init];
        imageView.image = [UIImage imageNamed:@"courseshare_bg_coachbg"];
        [self addSubview:imageView];
        self.imageView = imageView;
        
        /**
         头像图片
         */
        UIImageView *headImageView = [[UIImageView alloc] init];
        headImageView.contentMode = UIViewContentModeScaleAspectFill;
        headImageView.backgroundColor = CSRedColor;
        headImageView.layer.cornerRadius = 30;
        headImageView.layer.masksToBounds = YES;
        [self addSubview:headImageView];
        self.headImageView = headImageView;
        
        /**
         标题
         */
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.font = [UIFont boldSystemFontOfSize:18];
        titleLabel.text = @"阿金";
        [self addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    /**
     背景图片
     */
    [self.imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.mas_equalTo(self);
    }];
    
    /**
     头像图片
     */
    [self.headImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self).offset(20);
        
        make.width.height.mas_equalTo(60);
        
        make.centerX.mas_equalTo(self);
    }];
    
    /**
     标题
     */
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.headImageView.mas_bottom).offset(10);
        
        make.centerX.mas_equalTo(self);
    }];
}
@end

